#coding=utf-8

def bubbleSort(list):
    """
    python 实现冒泡排序算法
    :param list:
    :return: a new list
    """
    for i in range(0, len(list)):
        for j in range(i+1, len(list)):
            if list[i] > list[j]:
                list[i], list[j] = list[j], list[i]
    return list

data = [1,2,4,3,5,9,7]

print 'bubble sort :'
print bubbleSort(data)



def whileFun(x):
    """
    while的用法
    :param x:
    :return: nothing
    """
    while x:
        if x == 8:
            print 'pass'
            pass
        elif x == 6:
            print 'continue'
            x -= 1
            continue
        elif x == 5:
            print 'break'
            break
        x -= 1
    else:
        print 'end'

print 'while的用法：'
whileFun(10)
print 'run the else : '
whileFun(4)


